<?php $this->load->view('qt/header'); ?>


<!--  PAPER WRAP -->
<div class="wrap-fluid">
    <div class="container-fluid paper-wrap bevel tlbr">

        <!-- CONTENT -->
        <!--TITLE -->
        <div class="row">
            <div id="paper-top">
                <div class="col-sm-12">
                    <h2 class="tittle-content-header">
                        <i class="qt-network"></i>
                        <span id="title-header">
                            <?php echo (isset($this->title_header)) ? $this->title_header : 'CHI TIẾT KHÁCH HÀNG';?>
                        </span>
                    </h2>
                </div>
            </div>
        </div>
        <!--/ TITLE -->
        <ul id="breadcrumb">
            <li><span class="entypo-home"></span></li>
            <li><i class="fa fa-lg fa-angle-right"></i></li>
            <li><a href="#main">Trang chủ</a></li>
        </ul>
        <div class="content-wrap"  style="margin-top: 10px; height: 900px;">
<?php
$n=0;
$array=array('cust_first_name','cust_last_name','cust_tax_code','cust_address','cust_phone','cust_email','cust_dob','cust_bank_account','cust_cmnd','cust_cmnd_date','cust_cmnd_images','cust_sex');
foreach($array as $v){
	if($this->data["result"][$v]!=""){
		$n+=1;
	}
}
$color="danger";
$px=round($n/(count($array))*100);
?>
<section class="vbox" id="detail_customer">
	<section class="scrollable">
		<section class="hbox stretch">
			<aside class="col-lg-4 bg-light lter b-r" style="padding-right: 0px !important;">
				<section class="vbox">
					<section class="scrollable">
						<div class="wrapper">
							<section class="panel no-border bg-bla lt">
								<div class="panel-body" style="padding: 0px !important;">
									<div class="row m-t-xl" style="padding: 0px !important; margin: 0px !important;">
										<div class="col-xs-12 text-center" style="padding: 0px !important;">
                                            <header class="qth" style="font-size: 12px; 
                                                            font-weight: bold;
                                                            border: 1px solid #bcbcbc;
                                                            width: 100%;
                                                            height: 35px;
                                                            padding-top: 6px;">Thông tin cá nhân</header>
											<div class="" style="border: 1px solid #bcbcbc;
                                                                 border-top: none;"><!-- inline -->
												<div  style="width: 140px; height: 140px; line-height: 140px;margin: 0 auto;">
													<div class="thumb-lg avatar">
														<img src="<?php echo base_url()?>/images/avatar.png" class="dker">
													</div>
													<canvas width="140" height="140" style="display: none;"></canvas>
													<input type="hidden" value="<?php echo $_REQUEST["id"]?>" id="cust_id"/>
												</div>
												<div class="col-xs-12">
													 <span class="text-lt font-bold pointer editable editable-click qtdax" id="dt_cust_first_name" data="cust_first_name">
													  <?php echo $this->data["result"]["cust_first_name"];?>
													  </span>
													
													
														 <span  class="text-lt font-bold pointer editable editable-click qtdax" id="dt_cust_last_name" data="cust_last_name">
													  <?php echo $this->data["result"]["cust_last_name"];?>
													  </span>
												</div>

												
                                                   
                                                     
                                                       </p>
                                                <p style="color: #ff6700;">
                                                <?php echo ucfirst(strtolower($this->data["result"]["cust_address"]));?></p>
											
                                            <div class="row m-t-lg">
											<div class="col-xs-6 col-xs-offset-3 text-center">											
												<div class="text-lt font-bold">
													<?php 
													$is_account = false;
														$per = $this->session->userdata('user_info');
														//print_r($per);
														$my_permisstion = $per["permission_apps"]["AM_SALE_SUPPORT"];
														if(isset($my_permisstion["user_type"])&&count($my_permisstion)>0&&$my_permisstion!=""){
															foreach($my_permisstion["user_type"] as $key => $v){
																if(strtoupper($key)=="IS_ACCOUNT"&&$v==1){							
																	$is_account =true;														
																}
															}
														}
														
														if($is_account){
														?>
														<form action="" method="POST" class="form_verify">
															<input type="hidden" name="mod" value="verify">
															<?php 
															if($this->data["result"]["cust_status"]==-2){
																echo '<button type="button" onclick="viewMsg(\'Khách hàng này đang chờ Sale Quản Lý Xử lý\')" class="btn btn-warning btn-s-lg">Đang bị confLict</button>';
															}else if($this->data["result"]["cust_status"]==0){
																if($px<100){
																	echo '<button type="button" onclick="viewMsg(\'Vui lòng cập nhật đầy đủ thông tin mới được xác nhận.<br/> Thông tin đang đã được cập nhật '.$px.'%\')" class="btn btn-danger btn-s-lg">Chưa xác nhận</button>';
																}else{
																	echo '<button type="button" onclick="validate_verify()" class="btn btn-danger btn-s-lg qtl"><li class="qt-cam" style="font-size: 22px; color: black;list-style: none; float: left;">&nbsp;</li>Chưa xác nhận</button>';
																}

															}else if($this->data["result"]["cust_status"]==1){
																echo '<button type="button" class="btn btn-primary btn-s-lg">Đã Xác Nhận</button>';
															}else{

															}
															?>
														</form>
														<?php }else{
															if($this->data["result"]["cust_status"]==-2){
																echo '<span class="label bg-warning">Đang bị confLict</span>';
															}else if($this->data["result"]["cust_status"]==0){
																
																echo '<span class="label bg-danger btn-s-lg qtl"><li class="qt-cam" style="font-size: 22px; color: black;list-style: none; float: left;">&nbsp;</li> Chưa xác nhận</span>';
																

															}else if($this->data["result"]["cust_status"]==1){
																echo '<span class="label bg-success">Đã Xác Nhận</span>';
															}else{

															}

														}?>
													</div>
												</div>
											</div>
                                            
											</div>
										</div>
									</div>
									<div class="wrapper m-t m-b  qtIn">
										<input type="hidden" id="comp_id" value="">
										<div class="row m-b" style="margin: 0px; padding: 0px;">
											<div class="col-xs-12 text-right qta qtto" > 
                                            <div class="col-xs-6">
                                            <small>Công ty</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold">
													<?php foreach($this->data["result_comp"] as $value){
														?>
														<a style="text-align: left; float: left" href="<?php echo base_url()?>/companies/detail?id=<?php echo $value["comp_id"]?>" class="pointer"><?php echo $value["comp_name"]?></a><br/>
														<?php 
													}
													?>
												</div>

                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>Ngày sinh</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable" style="color: #424242;" 
                                              id="dt_dob" data-type="date" data="cust_dob"  data-type="date" >
													<?php echo $this->data["result"]["cust_dob"];?>
												</div>

                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>Điện thoại</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable"  id="dt_phone" data="cust_phone" style="color: #424242;">
													<?php echo $this->data["result"]["cust_phone"];?>
												</div>

                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>Email</small>
                                            </div>
                                            <div class="col-xs-6 qtr" >
                                            <div class="text-lt font-bold editable cust_email"  id="dt_email" data="cust_email">
													<?php echo $this->data["result"]["cust_email"];?>
												</div>

                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>CMND</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable" style="color: #424242;" id="dt_phone" data="cust_cmnd">
													<?php echo $this->data["result"]["cust_cmnd"];?>
												</div>

                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none;" > 
                                            <div class="col-xs-6">
                                            <small>Ngày Cấp CMND</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="text-lt font-bold editable" style="color: #424242;" id="dt_email" data="cust_cmnd_date"  data-type="date" >
													<?php echo $this->data["result"]["cust_cmnd_date"];?>
												</div>

                                            </div>
											</div>
                                            
                                            <div class="col-xs-12 text-right qta" style="border-top: none; height: 110px !important" > 
                                            <div class="col-xs-6">
                                            <small>Tài khoản ngân hàng</small>
                                            </div>
                                            <div class="col-xs-6 qtr">
                                            <div class="content text-lt font-bold pointer editable editable-pre-wrapped editable-click qttera" 
                                             id="dt_phone" data="cust_bank_account" data-type="textarea" >
													<?php echo $this->data["result"]["cust_bank_account"];?>
												</div>

                                            </div>
											</div>
										
										</div>

										</div>
									</div>
									<footer class="panel-footer dk text-center no-border" style="display: none;">
										<div class="row pull-out">
											<div class="col-xs-4">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
											<div class="col-xs-4 dker">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
											<div class="col-xs-4">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
										</div>
									</footer>
								</section>
							</div>
						</section>
					</section>
				</aside>
				<aside class="col-lg-8 b-l no-padder" style="padding-left: 0px !important;">
					<section class="vbox">
						<section class="scrollable">
							<div class="wrapper" style="width: 100%;">
								<div class="msg-data"></div>
								<section class="panel panel-warning portlet-item qtbot">
									<header class="panel-heading qth">Hình ảnh CMND</header>
									<div class="row">
										<div class="col-lg-12">
											<ul class="list-inline" id="img_cmnd_result" style="padding: 15px 15px 0;">
												<?php
												$imageUpload = json_decode($this->data["result"]["cust_cmnd_images"],true);
												if(count($imageUpload)>0){
													foreach($imageUpload as $num=> $val){
														echo '<li class="im_cmnd_'.$num.'">
														<a href="'.$val.'" class="thumbnail fancybox"><img src="'.$val.'" style="width:150px;height:120px;"></a>
														<span class="img-remove" onclick="remove_img_cmnd('.$_REQUEST["id"].','.$num.');"><i class="fa fa-times"></i></span>
													</li>';
												}
											}										
											?>
										</ul>
									</div>
								</div>
								<div class="row">
									<div class="col-lg-11 col-lg-offset-1" style="margin-left: 20px !important;">
										<div id="img_cmnd">
                                        
                                        </div>
									</div>
								</div>
							</section>
							<?php 
							$user_info =  $this->session->userdata('user_info');
								$my_permisstion = $user_info["permission_apps"]["AM_SALE_SUPPORT"];			

							
							if($user_info['user_type']==1&&isset($my_permisstion["customer"]["list_sale"])){?>	
							<section class="panel-default">
								<header class="panel-heading qtthead">
                                <li class="qt-user qtthead1">&nbsp;</li>
                                Sale Đang Quản Lý</header>
									<section class="panel panel-default list-sale qts" id="progressbar">
										<header class="panel-heading qtph">
											<div class="row m-t-sm">
												<div class="col-sm-7 m-b-xs">													
													<div class="btn-group">
														<button type="button" class="btn qtbt" onclick="selectListSale(0)" title="Refresh"><i class="qt-refesht qtio"></i></button>
														<button type="button" class="btn qtbt" onclick="delectCustUser()" title="Remove"><i class="qt-trash qtio"></i></button>
													</div>
													<a href="<?php echo base_url("customer/full_sale_view"); ?>" data-toggle="ajaxModal" style="background: #bcbcbc;" class="btn qtbt" title="Thêm Sale Cho Khách Hàng"><i class="qt-add2 qtio"></i></a> 
												</div>
												<div class="col-sm-5 m-b-xs">
													
														<div class="input-group">
                                                        <input type="text" name="where" placeholder="Search" class="input-sm form-control" value="<?php echo $this->input->post('where')?>"> <span class="input-group-btn"> 
                                                         
                                                        <button type="submit" onclick="selectListSale(0)" class="qtbtn"><li class="qt-search" style="float: left; list-style: none; margin-top: 4px; width: 10px;">&nbsp;</li>Tìm kiếm</button>
                                                        </span> </div>
                                                        
													
												</div>
											</div>
										</header>
										<table class="table table-striped table-condensed table-hover table-bordered">
											<thead>
												<tr>
													<th width="20"><label class="checkbox m-n i-checks"><input type="checkbox"><i></i></label></th>
													<th width="170">Họ tên</th>
													<th width="120">Số Điện Thoại</th>
													<th>Ngành Hàng</th>
													<th width="120">Thay Đổi Ngành Hàng</th>
												</tr>
											</thead>
											<tbody class="data-table">		


											</tbody>
										</table>
										<footer class="footer bg-white b-t">
										   <div class="row text-center-xs">
										      <div class="col-md-12 col-sm-12 text-center text-center-xs">
										         <ul class="paging-sale pagination pagination-sm m-t-sm m-b-none"></ul>
										      </div>
										   </div>
										</footer>
									</section>	
							</section>						
							<?php }?>
                            <section class="content">
                            <div class="time-wrap">
                                <div class="row">
                                    <div class="col-md-12">
                                        <!-- The time line -->
                                        <ul class="timeline">
                                            <?php 
                                            $qtdate = '';
            								    foreach($this->data["feed_result"] as $value){
            								?>
                                            <!-- timeline time label -->
                                            <?php if($qtdate == '' || $qtdate != @date("d/m/Y",$value["feed_action_time"]) ): ?>
                                            <?php $qtdate = @date("d/m/Y",$value["feed_action_time"]); ?>
                                            <li class="time-label">
                                                <span class="bg-red">
                                                    <?php echo $qtdate; ?>
                                                </span>
                                            </li>
                                            <?php endif; ?>
                                            <!-- /.timeline-label -->
                                            
                                            
                                            <!-- timeline item -->
                                            <li>
                                                <i class="fa bg-time" style="background: url('<?php echo base_url('public/theme/'.T); ?>/images/seo.png') !important;"></i>
                                                <div class="timeline-item">
                                                    
                                                    <span class="time" style="margin-left: 10px; color: #424242; margin-top: 10px !important;"><i class="qt-clock1" style="color: #424242;"></i> <?php echo @date("h:i:s",$value["feed_action_time"]); ?></span>
                                                    <span class="time"  style="color: #424242; margin-top: 10px !important;"><i class="qt-time1" style="color: #424242;"></i> <?php echo @date("d/m/Y",$value["feed_action_time"]); ?></span>
                                                    <h3 class="timeline-header"><a href="#" style="font-weight: bold;"><?php echo $this->session->userdata('fullname') ?></a> 
                                                    <span style="margin: 0px 10px 0px 20px;">gặp khách hàng</span>
                                                    <a class="mr" href="<?php echo base_url()?>customer/detail?id=<?php echo $value["cust_id"]?>"><?php echo $value["cust_first_name"]." ".$value["cust_last_name"]; ?></a>
                                                    </h3>
                                                    
                                                    <div class="timeline-body" style="color: #808080;">
                                                        <?php echo $value["feed_content"]?>
                                                    </div>
                                                </div>
                                            </li>
                                            <!-- END timeline item -->
                                            
                                            <?php } ?>
                                            <li>
                                                <i class="fa bg-time">...</i>
                                            </li>
                                        </ul>
                                    </div>
                                    <!-- /.col -->
                                </div>
                                <!-- /.row -->   													
						</div>
                        </section>
                        
                        
					</section>
				</section>
			</aside>

		</section>
	</section>
</section>

</div>
<div class="content-wrap" id="show-content2"></div>
<div class="content-wrap"> 
<?php $this->load->view('qt/footer'); ?>

<script>
selectListSale(0);
</script>